<!--{template header}-->
<!--{if $_GET[op] == 'delete'}-->
<!--{else}-->
<script language="javascript" src="image/editor/editor_function.js"></script>
<script type="text/javascript">
	function checkselect(){
		var subject = $('catid');
	  			if (subject) {
	    			if(subject.value=='a') {
	    				alert("不能选择顶级目录！");
	        		   		return false;
	    			}
			    }
	}
	function validate(obj) {
			var subject = $('catid');
	  			if (subject) {
	    			if(subject.value=='a') {
	    				alert("不能选择顶级目录！");
	        		   		return false;
	    			}
			    }
	    var subject = $('subject');
	    if (subject) {
	    	var slen = strlen(subject.value);
	        if (slen < 1 || slen > 80) {
	            alert("标题长度(1~80字符)不符合要求");
	            subject.focus();
	            return false;
	        }
	    }
	     var subject = $('endtime');
	     var subject1 = $('isadmin');
	     
	    if (subject) {
	    	var slen = subject.value;
	    	var slen1 = subject1.value;
	    	//if(slen1<1){
	        	if (slen < 1 || slen > 120) {
	            	alert("日期有效期(1~120天)不符合要求");
	            	subject.focus();
	            	return false;
	       		}
	    	//}
	    }						
	    if($('seccode')) {
			var code = $('seccode').value;
			var x = new Ajax();
			x.get('cp.php?ac=common&op=seccode&code=' + code, function(s){
				s = trim(s);
				if(s != 'succeed') {
					alert(s);
					$('seccode').focus();
	           		return false;
				} else {
					uploadEdit(obj);
					return true;
				}
			});
	    } else {
	    	uploadEdit(obj);
	    	return true;
	    }
	}
	function edit_album_show(id) {
		var obj = $('uchome-edit-'+id);
		if(id == 'album') {
			$('uchome-edit-pic').style.display = 'none';
		}
		if(id == 'pic') {
			$('uchome-edit-album').style.display = 'none';
		}
		if(obj.style.display == '') {
			obj.style.display = 'none';
		} else {
			obj.style.display = '';
		}
	}
</script>
 <h2 class="title"><img src="image/app/news.gif" /><!--{if $newsid}-->编辑爆料<!--{else}-->发布新爆料<!--{/if}--></h2>
 
<style>
	.userData {behavior:url(#default#userdata);}
</style>

<div class="c_form">
	<form method="post" action="news.php?ac=new" enctype="multipart/form-data">
		<table cellspacing="4" cellpadding="4" width="100%" class="newstable">
			<tr>
				<td>
					<input type="hidden"  name="newsid" value="$news[newsid]"   />
					<input type="hidden"  name="uid" value="$news[uid]"   />
					<input type="hidden"  name="isadmin" value="$isadmin"   />
					<select name="catid" id="catid" onchange="checkselect();"  >
						<option value="a">选择分类</option>
							<!--{loop $newslist $value}-->
									<option value="a" >---$value[catname]---</option>
								<!--{loop $newslist_cat $value_cat}-->
								<!--{if $value_cat[parentid]==$value[catid]}-->
									<!--{if $value_cat[catid]==$news[catid]}-->
										<option value="$value_cat[catid]" selected>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$value_cat[catname]</option>
										<!--{else}-->	
										<option value="$value_cat[catid]" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$value_cat[catname]</option>
									<!--{/if}-->	
									<!--{/if}-->
								<!--{/loop}-->
							<!--{/loop}-->
					</select>
					<input type="text" class="t_input" id="subject" name="subject" value="$news[subject]" size="60" /> &nbsp;&nbsp;&nbsp;有效期:&nbsp;<input onkeyup="value=value.replace(/[^\d]/g,'')" type="text" class="t_input" size="5" id="newsdate" name="endtime" value="$news[endtime]">&nbsp;天
				</td>
			</tr>
			<tr>
				<td>事发地点:&nbsp;&nbsp;
				    <script type="text/javascript" src="news/js/script_city.js"></script>
                <SCRIPT LANGUAGE="JavaScript">
                    var $ = function(ID){ return document.getElementById(ID); };
                    window.onload = function() { 
                        attachSelect(0, [$("province"), $("city"), $("subcity")], aMatrix,["$news[province]","$news[city]","$news[subcity]",]); 
	                };
                </SCRIPT>
                <select id="province" name="province" >省份</select>
                <select id="city" name="city">市</select>
                <select id="subcity" name="subcity">区县</select>
                (如不选项默认为上级选项区)
				 </td>
			</tr>
			<tr>
				<td>
				<textarea class="userData" name="message" id="uchome-ttHtmlEditor" style="height:100%;width:100%;display:none;border:0px">$news[detail]</textarea>
				<iframe src="editor.php?charset=$_SC[charset]&allowhtml=$allowhtml" name="uchome-ifrHtmlEditor" id="uchome-ifrHtmlEditor" scrolling="no" border="0" frameborder="0" style="width:100%;border: 1px solid #C5C5C5;" height="400"></iframe>
				</td>
			</tr>
		</table>
		<input type="hidden" name="newssubmit" value="true" />
		<input type="button" id="addnews" name="addnews" value="提交发布" onclick="validate(this);" style="display: none;" />
		<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
	</form>
	<!--{if !$news['uid'] || $news['uid']==$_SGLOBAL['supe_uid']}-->
	<table cellspacing="4" cellpadding="4" width="100%" class="newstable">
		<tr><th width="58">图片</th><td>
		<input type="button" name="clickbutton[]" value="上传图片" class="button" onclick="edit_album_show('pic')">
		<input type="button" name="clickbutton[]" value="插入图片" class="button" onclick="edit_album_show('album')">
		</td></tr>
	</table>
	<!--{/if}-->
	<table cellspacing="4" cellpadding="4" width="100%" id="uchome-edit-pic" class="newstable" style="display:none;">
		<tr>
			<th width="60">&nbsp;</th>
			<td>
				<strong>选择图片</strong>: 
				<table summary="Upload" cellspacing="2" cellpadding="0">
					<tbody id="attachbodyhidden" style="display:none">
						<tr>
							<td>
								<form method="post" id="upload" action="cp.php?ac=upload" enctype="multipart/form-data" target="uploadframe" style="background: transparent;">
									<input type="file" name="attach" style="border: 1px solid #CCC;" />
									<span id="localfile"></span>
									<input type="hidden" name="uploadsubmit" id="uploadsubmit" value="true" />
									<input type="hidden" name="albumid" id="albumid" value="0" />
									<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
								</form>
							</td>
						</tr>
					</tbody>
					<tbody id="attachbody"></tbody>
				</table>
				<strong>存储相册</strong>: 
				<table cellspacing="2" cellpadding="0">
					<tr>
						<td>
							<select name="albumid" id="uploadalbum" onchange="addSort(this)">
								<option value="0">请选择相册</option>
								<!--{loop $albums $value}-->
								<option value="$value[albumid]">$value[albumname]</option>
								<!--{/loop}-->
								<option value="addoption" style="color:red;">+新建相册</option>
							</select>
							<script src="source/script_upload.js" type="text/javascript"></script>
							<iframe id="uploadframe" name="uploadframe" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<table cellspacing="4" cellpadding="4" width="100%" class="newstable" id="uchome-edit-album" style="display:none;">
		<tr>
			<th width="60">&nbsp;</th>
			<td>
				选择相册: <select name="view_albumid" onchange="picView(this.value)">
					<option value="none">选择一个相册</option>
					<option value="0">默认相册</option>
					<!--{loop $albums $value}-->
					<option value="$value[albumid]">$value[albumname]</option>
					<!--{/loop}-->
				</select> (点击图片可以插入到内容中)
				<div id="albumpic_body"></div>
			</td>
		</tr>
	</table>
	<table cellspacing="4" cellpadding="4" width="100%" class="newstable">
		<tr>
			<th width="60">&nbsp;</th>
			<td><input type="button" id="issuance" onclick="document.getElementById('addnews').click();" value="保存发布" class="submit" /></td>
		</tr>
	</table>
</div>
<!--{/if}-->
<!--{template footer}-->